class Solution(object):
    def nextGreaterElements(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        nums_length = len(nums)
        answer = [-1 for _ in range(nums_length)]
        mono_stack = []

        for i in range(2*nums_length - 1, -1, -1):
            while mono_stack and mono_stack[-1] <= nums[i % nums_length]:
                mono_stack.pop()
            
            answer[i % nums_length] = -1 if not mono_stack else mono_stack[-1]
            mono_stack.append(nums[i % nums_length])
        return answer